

def countdown(n):
    print('Counting down from{}'.format(n))
    while n >= 0:
        new_value = (yield n)
        print('[countdown] n:{}'.format(n))
        if new_value is not None:
            n = new_value
        else:
            n -= 1


def main(*args, **kwargs):
    cd = countdown(5)
    for n in cd:
        import pdb; pdb.set_trace()
        print(n)
        # if n == 5:
        #     cd.send(3)


if __name__ == '__main__':
    main()
